﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyDMS.BusinessLayer;

public partial class DocumentTypes : PageBaseClass
{
    DocumentTypeFactory dtFactory;
    protected void Page_Load(object sender, EventArgs e)
    {
        dtFactory = new DocumentTypeFactory();
        List<DocumentType> dTypes = dtFactory.GetAllBy(DocumentType.DocumentTypeFields.Office_Code, _author.office_Code);
        this.gvDtypes.DataSource = dTypes;
        this.gvDtypes.DataBind();
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        DocumentType docType = new DocumentType();
        docType.Type_Name = txtJobName.Text;
        docType.File_Extension = txtExtension.Text;
        docType.Type_Desc = txtDescription.Text;
        docType.Office_Code = _author.office_Code;

        dtFactory = new DocumentTypeFactory();
        if (dtFactory.Insert(docType))
        {
            lblMessage.Text = "Saved Successfully";
        }
        else
        {
            lblMessage.Text = "Error!";
        }
        lblMessage.Visible = true;
    }
}
